#ifndef RAFT_LOG
#define RAFT_LOG
#include "ffz/bit-ops.h"
#define LOG_APPLY 1
#define LOG_COMMIT 2
typedef struct RaftLog
{
    uint16_t index;
    uint16_t term;
    uint8_t status;
    uint8_t action;
} RaftLog;
/**
 * to get the last log's index
 * */
uint16_t getLastLogIndex();
/**
 * get the raft log by index
 * @param index the raft log index
 * @return raft log
 * */
RaftLog *getRaftLog(uint16_t index);
/**
 * @param log a RaftLog which will be added ..
 * */
void setRaftLog(RaftLog *log);
/**
 * @param length set the raft-log's length
 * */
void setRaftLogLastIndex(uint16_t index);
/**
 * add a raftLog, which will change the log status.
 * */
void addRaftLog(uint16_t term, uint8_t status, uint8_t action);

//Some tool functions
/**
 * get the newest log's index and term
 * @param lastLogIndex lastLogIndex'pointer
 * @param lastLogTerm lastLogTerm'pointer
 * */
void getLastLogIndexAndTerm(uint16_t *lastLogIndex, uint16_t *lastLogTerm);

/**
 * set the commit index
 * @param the commitIndex
 * */
void setCommitIndex(uint16_t index);
/**
 * get the commit index
 * */
uint8_t getCommitIndex();
#endif